package com.tiger.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@SuppressWarnings({ "rawtypes", "unchecked" })
public class FilterRegistrationConfig {

	
	@Bean
	public FilterRegistrationBean loginFilterRegistration() {
		FilterRegistrationBean registration = new FilterRegistrationBean(new LoginFilter());
		registration.addUrlPatterns("/*"); //
		registration.addInitParameter("excludedUrls", "/resources/*,/**/login*"); 
		registration.setName("loginFilter");
		registration.setOrder(1);
		return registration;
	}
	
	@Bean
	public FilterRegistrationBean decoratorFilterRegistration() {
		FilterRegistrationBean registration = new FilterRegistrationBean(new DecoratorFilter());
		registration.addUrlPatterns("/*"); //
		registration.addInitParameter("excludedUrls", "/resources/*,/**/login*"); 
		registration.setName("decoratorFilter");
		registration.setOrder(2);
		return registration;
	}
}
